﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System;

public abstract class UIBase : MonoBehaviour
{
    public  string uiType;
    public  CanvasGroup cg;
   // public  UIManager uIManager;

    private void Awake()
    {
        cg = this.gameObject.AddComponent<CanvasGroup>();
    }

   

   public UIBase GetUI(string uiType)
    {
        UIBase ui = null;
        if (UIManager.instance. uiTypePanelDic.ContainsKey(uiType))
        {
            ui = UIManager.instance.uiTypePanelDic[uiType];
        }
        return ui;
    }

    public  void ShowUI() 
    {
        cg.alpha = 1;
        cg.interactable = true;
        cg.blocksRaycasts = true;
        this.gameObject.SetActive(true);
    }





    public virtual void HideUI()
    {
        cg.alpha = 0;
        cg.interactable = false;
        cg.blocksRaycasts = false;
    }

    TipPanel tipPanel;
    public void ShowTip(string content ,Action cb = null)
    {
        if (tipPanel==null)
        {
            tipPanel = GetUI(UIType.TipPanel) as TipPanel;
        }

        tipPanel.ShowTip(content, cb);

    }



  }
